﻿cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

if (WIN32)
    set(CROSS_WIN ON)
elseif(NOT (${CROSS_WIN}))
    execute_process(
        COMMAND bash "-c" "cat /etc/os-release | grep ^ID= | sed -e 's/ID=//'"
        OUTPUT_VARIABLE LINUX_DISTRO_ID
        OUTPUT_STRIP_TRAILING_WHITESPACE
    )

    if(LINUX_DISTRO_ID STREQUAL altlinux)
        set(IS_ALT_LINUX ON)
    endif()
endif()

project(SIMODO-edit)

include(${CMAKE_SOURCE_DIR}/version/version.cmake)
include(${CMAKE_SOURCE_DIR}/data/data.cmake)

SET(CMAKE_CXX_FLAGS "-pthread -fPIC -Werror -pedantic-errors -Wall -Wextra -Wpedantic -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wextra-semi -Wfloat-equal -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wsign-promo")

SET(CMAKE_CXX_FLAGS_RELEASE        "-O3")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O0 -g --coverage")
SET(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_compile_definitions(BOOST_DLL_USE_STD_FS)

if (${CROSS_WIN})
    add_compile_definitions(CROSS_WIN)
endif()

find_package(Boost)

### Domains & tools ###########################################################

### Статические библиотеки
add_subdirectory(src/libs/ast)
add_subdirectory(src/libs/bormental)
add_subdirectory(src/libs/inout)
add_subdirectory(src/libs/utility)
add_subdirectory(src/libs/variable)
add_subdirectory(src/libs/module)
add_subdirectory(src/libs/tp)
add_subdirectory(src/libs/lsp-client)
add_subdirectory(src/libs/lsp-server)
add_subdirectory(src/libs/parser)
add_subdirectory(src/libs/loom)
add_subdirectory(src/libs/interpret)
# Библиотека setup реализована в виде заготовки
add_subdirectory(src/libs/setup)

### Функциональное тестирование статических библиотек (автотесты)
add_subdirectory(src/test/libs/inout/tokenizer)
add_subdirectory(src/test/libs/json/serialization/JsonSerialization)
add_subdirectory(src/test/libs/json/serialization/LexicalParametersLoader)
add_subdirectory(src/test/libs/json/AnalyzeData)
add_subdirectory(src/test/libs/setup/load)
add_subdirectory(src/test/libs/module/loader)
add_subdirectory(src/test/libs/module/collector) 
add_subdirectory(src/test/libs/lsp/client)

### Семантические компоненты языков
add_subdirectory(src/semantics/script)
add_subdirectory(src/semantics/SystemVerilog)

### Инструменты командной строки
add_subdirectory(src/tools/grammatize)
add_subdirectory(src/tools/parse)
add_subdirectory(src/tools/interpret)

### Модули (динамически загружаемые компоненты)
add_subdirectory(src/modules/test)
add_subdirectory(src/modules/script/array)
add_subdirectory(src/modules/script/math)
add_subdirectory(src/modules/tokenizers/tokenizer-main)
add_subdirectory(src/modules/tokenizers/tokenizer-doxygen)
add_subdirectory(src/modules/tokenizers/tokenizer-substitutions) 

### Языковые сервера
add_subdirectory(src/servers/lsp/json)
add_subdirectory(src/servers/lsp/simodo)

### GUI #######################################################################

### Сторонние библиотеки
add_subdirectory(src/third-parties/QtNodes)

### GUI редактора (оболочка и плагины)
add_subdirectory(src/shell)
add_subdirectory(src/plugins/built-in/documents/general-text)
add_subdirectory(src/plugins/built-in/documents/image-viewer)
add_subdirectory(src/plugins/built-in/panels/home-directory)
add_subdirectory(src/plugins/built-in/panels/find-replace)
add_subdirectory(src/plugins/built-in/panels/report-text)
add_subdirectory(src/plugins/built-in/panels/markdown-preview)
# Заготовки
add_subdirectory(src/plugins/built-in/documents/setup)

### Плагины отображения результатов моделирования
add_subdirectory(src/plugins/modeling/output/chart-panel)
add_subdirectory(src/plugins/modeling/output/graph3d-panel)
add_subdirectory(src/plugins/modeling/output/cockpit-panel)
add_subdirectory(src/plugins/modeling/output/mechanoid-panel)

### Наброски и примеры плагинов
add_subdirectory(src/plugins/drafts/visual-calculator/visual-document)
add_subdirectory(src/plugins/drafts/visual-calculator/toolkit-panel)
add_subdirectory(src/plugins/drafts/visual-calculator/properties-panel)

### Плагины моделирования (раннеры)
add_subdirectory(src/plugins/built-in/runners/record-player)
add_subdirectory(src/plugins/built-in/runners/stars-interpreter)
add_subdirectory(src/plugins/built-in/runners/simodo-lsp-support)
add_subdirectory(src/plugins/built-in/runners/document-preview)

